package com.example.boot.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.boot.pojo.MxGroupPersonnelEntity;
import com.example.boot.pojo.MxUserGroupEntity;
import com.example.boot.service.MxGroupPersonnelService;
import com.example.boot.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 
 *
 * @author yy
 * @email yangxxil01@sina.com
 * @date 2022-01-08 14:35:28
 */
@RestController
@RequestMapping("mxgrouppersonnel")
public class MxGroupPersonnelController {
    @Autowired
    private MxGroupPersonnelService mxGroupPersonnelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Long groupId){
        LambdaQueryWrapper<MxGroupPersonnelEntity> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(MxGroupPersonnelEntity::getGroupId,groupId);


        return R.ok(mxGroupPersonnelService.list(lambdaQueryWrapper));

    }


    /**
     * 信息
     */
    @RequestMapping("/info/{personnelId}")
    public R info(@PathVariable("personnelId") Long personnelId){
		MxGroupPersonnelEntity mxGroupPersonnel = mxGroupPersonnelService.getById(personnelId);

        return R.ok().put("mxGroupPersonnel", mxGroupPersonnel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MxGroupPersonnelEntity mxGroupPersonnel){
		mxGroupPersonnelService.save(mxGroupPersonnel);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MxGroupPersonnelEntity mxGroupPersonnel){
		mxGroupPersonnelService.updateById(mxGroupPersonnel);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] personnelIds){
		mxGroupPersonnelService.removeByIds(Arrays.asList(personnelIds));

        return R.ok();
    }

}
